package com.doctcloud.hisinfo.histable.domain.ordadm;
import com.baomidou.mybatisplus.annotation.TableName;
import com.doctcloud.common.core.annotation.Excel;
import com.doctcloud.common.core.annotation.NotZero;
import com.doctcloud.common.core.utils.StringUtils;
import lombok.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Objects;

import static com.doctcloud.common.core.utils.StringUtils.trim;

/**
 * @ClassName 医嘱计价项目
 * @Author samula
 * @Descripe product by com.doctcloud
 * @Data 2025-09-23 3:05
 **/
//@TableName("orders_costs")
@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@EqualsAndHashCode(of = {"patientId", "visitId", "orderNo","orderSubNo"})
public class OrdersCostsDo implements Serializable {
    private static final long serialVersionUID = 1L;
    @Excel(name = "患者ID")
    private String patientId;
    @Excel(name = "住院标识号",cellType = Excel.ColumnType.NUMERIC)
    private Integer visitId;
    @Excel(name = "医嘱号",cellType = Excel.ColumnType.NUMERIC)
    private Integer orderNo;
    @Excel(name = "医嘱子序号",cellType = Excel.ColumnType.NUMERIC)
    private Integer orderSubNo;
    @Excel(name = "顺序号",cellType = Excel.ColumnType.NUMERIC)
    private Integer itemNo;
    @Excel(name = "项目类别代码")
    private String itemClass;
    @Excel(name = "项目名称")
    @NotBlank(message = "项目名称不能为空")
    private String itemName;
    @Excel(name = "项目代码")
    @NotBlank(message = "项目代码不能为空")
    private String itemCode;
    @Excel(name = "项目规格")
    @NotBlank(message = "项目规格不能为空")
    private String itemSpec;
    @Excel(name = "项目单位")
    @NotBlank(message = "项目单位不能为空")
    private String units;
    @Excel(name = "数量",cellType = Excel.ColumnType.NUMERIC)
    @NotZero(message = "数量不能为null或0")
    private Integer amount;
    @Excel(name = "总数量",cellType = Excel.ColumnType.NUMERIC)
    @NotZero(message = "总数量不能为null或0")
    private Integer totalAmount;
    @Excel(name = "总金额",cellType = Excel.ColumnType.NUMERIC)
    @NotNull
    private Double costs;

    @Data
    public static class primaryKey {
        private final String patientId;
        private final Integer visitId;
        private final Integer orderNo;
        private final Integer orderSubNo;
        private final Integer itemNo;
        public primaryKey(String patientId,Integer visitId, Integer orderNo,Integer orderSubNo,Integer itemNo) {
            this.patientId = patientId;
            this.visitId = visitId;
            this.orderNo = orderNo;
            this.orderSubNo = orderSubNo;
            this.itemNo = itemNo;
        }
    }

    public void setItemClass(String itemClass) { this.itemClass = trim(itemClass); }

    public void setItemName(String itemName) {
        this.itemName = trim(itemName);
    }

    public void setItemCode(String itemCode) { this.itemCode = trim(itemCode); }

    public void setItemSpec(String itemSpec) {
        this.itemSpec = trim(itemSpec);
    }

    public void setUnits(String units) {
        this.units = trim(units);
    }

}
